<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是学习uboot顶层Makefile的相关笔记。若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV05-01-uboot-06-顶层Makefile-01-基础分析">
<meta property="og:url" content="https://sumumm.github.io/post/aadd7195.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是学习uboot顶层Makefile的相关笔记。若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730101206553.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730101506292.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730101655745.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730101821718.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730101935202.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730102338747.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730102605146.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730103740213.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730103928244.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730110043912.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730110807180.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730111047127.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730111512235.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730113258820.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730113557320.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730114148025.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730115029116.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730120749352.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730120828665.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730121214740.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730121307139.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730121415328.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730121536471.png">
<meta property="article:published_time" content="2023-09-08T11:22:59.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.041Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="(ALPHA)LV05-uboot与内核">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730101206553.png">


<link rel="canonical" href="https://sumumm.github.io/post/aadd7195.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://sumumm.github.io/post/aadd7195.html","path":"post/aadd7195.html","title":"LV05-01-uboot-06-顶层Makefile-01-基础分析"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV05-01-uboot-06-顶层Makefile-01-基础分析 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E7%89%88%E6%9C%AC%E5%8F%B7%E4%B8%8EMAKEFLAGS-%E5%8F%98%E9%87%8F"><span class="nav-text">一、版本号与MAKEFLAGS 变量</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%89%88%E6%9C%AC%E5%8F%B7"><span class="nav-text">1. 版本号</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-MAKEFLAGS-%E5%8F%98%E9%87%8F"><span class="nav-text">2. MAKEFLAGS 变量</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E8%BE%93%E5%87%BA%EF%BC%9F"><span class="nav-text">二、输出？</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E5%91%BD%E4%BB%A4%E8%BE%93%E5%87%BA"><span class="nav-text">1. 命令输出</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E9%9D%99%E9%BB%98%E8%BE%93%E5%87%BA"><span class="nav-text">2. 静默输出  </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E8%AE%BE%E7%BD%AE%E7%BC%96%E8%AF%91%E7%BB%93%E6%9E%9C%E8%BE%93%E5%87%BA%E7%9B%AE%E5%BD%95"><span class="nav-text">3. 设置编译结果输出目录  </span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E4%BB%A3%E7%A0%81%E6%A3%80%E6%9F%A5%E5%92%8C%E6%A8%A1%E5%9D%97%E7%BC%96%E8%AF%91"><span class="nav-text">三、代码检查和模块编译  </span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E4%BB%A3%E7%A0%81%E6%A3%80%E6%9F%A5"><span class="nav-text">1. 代码检查</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E6%A8%A1%E5%9D%97%E7%BC%96%E8%AF%91"><span class="nav-text">2. 模块编译</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9B%9B%E3%80%81%E6%9E%B6%E6%9E%84%E7%9B%B8%E5%85%B3"><span class="nav-text">四、架构相关</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E8%8E%B7%E5%8F%96%E4%B8%BB%E6%9C%BA%E6%9E%B6%E6%9E%84%E5%92%8C%E7%B3%BB%E7%BB%9F"><span class="nav-text">1. 获取主机架构和系统  </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E8%AE%BE%E7%BD%AE%E7%9B%AE%E6%A0%87%E6%9E%B6%E6%9E%84%E3%80%81%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91%E5%99%A8%E5%92%8C%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="nav-text">2. 设置目标架构、交叉编译器和配置文件  </span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%94%E3%80%81scripts-Kbuild-include"><span class="nav-text">五、scripts&#x2F;Kbuild.include  </span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%85%AD%E3%80%81%E5%8F%98%E9%87%8F%E7%9B%B8%E5%85%B3"><span class="nav-text">六、变量相关</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91%E5%B7%A5%E5%85%B7%E5%8F%98%E9%87%8F%E8%AE%BE%E7%BD%AE"><span class="nav-text">1. 交叉编译工具变量设置  </span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E5%AF%BC%E5%87%BA%E5%85%B6%E4%BB%96%E5%8F%98%E9%87%8F"><span class="nav-text">2. 导出其他变量  </span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/aadd7195.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV05-01-uboot-06-顶层Makefile-01-基础分析 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV05-01-uboot-06-顶层Makefile-01-基础分析
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-09-08 19:22:59" itemprop="dateCreated datePublished" datetime="2023-09-08T19:22:59+08:00">2023-09-08</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/" itemprop="url" rel="index"><span itemprop="name">02IMX6ULL平台</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/" itemprop="url" rel="index"><span itemprop="name">LV05-uboot与内核</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>5.9k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>21 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是学习uboot顶层Makefile的相关笔记。若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>Windows版本</td>        <td align="left">windows11</td>    </tr>    <tr>        <td align="center">Ubuntu版本</td>        <td align="left">Ubuntu16.04的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 16 Pro</td>        <td align="left">16.2.3 build-19376536</td>      </tr>    <tr>        <td align="center">终端软件</td>        <td align="left">MobaXterm(Professional Edition v23.0 Build 5042 (license))</td>      </tr>    <tr>        <td align="center">Linux开发板</td>        <td align="left">正点原子 i.MX6ULL Linux 阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，NXP提供的版本为uboot-imx-rel_imx_4.1.15_2.1.0_ga(使用的uboot版本为U-Boot 2016.03)</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.15(NXP官方提供)</td>      </tr>    <tr>        <td align="center">Win32DiskImager</td>        <td align="left">Win32DiskImager v1.0</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="5">官方网站</td>        <td align="left"><a href="https://www.arm.com/" target="_blank">https://www.arm.com/</a></td>        <td align="left">ARM官方网站，在这里我们可以找到Cotex-Mx以及ARMVx的一些文档</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/" target="_blank">https://www.nxp.com.cn/ </a></td>        <td align="left">NXP官方网站</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxpic.org.cn/" target="_blank">https://www.nxpic.org.cn/</a></td><td align="left">NXP 官方社区</td>    </tr>    <tr>        <td align="left"><a href="https://u-boot.readthedocs.io/en/latest/" target="_blank">https://u-boot.readthedocs.io/en/latest/</a></td><td align="left">u-boot官网</td>    </tr>    <tr>        <td align="left"><a href="https://www.kernel.org/" target="_blank">https://www.kernel.org/</a></td><td align="left">linux内核官网</td>    </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="4">NXP</td>        <td align="left"><a href="https://github.com/nxp-imx" target="_blank">https://github.com/nxp-imx</a></td>        <td align="left">NXP imx开发资源GitHub组织，里边会有u-boot和linux内核的仓库</td>    </tr>    <tr>        <td align="left"><a href="https://elixir.bootlin.com/linux/latest/source" target="_blank">https://elixir.bootlin.com/linux/latest/source</a></td>        <td align="left">在线阅读linux kernel源码</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/linux-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga" target="_blank">nxp-imx/linux-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga</a></td>        <td align="left">NXP linux内核仓库tags中的rel_imx_4.1.15_2.1.0_ga</td>    </tr>    <tr>        <td align="left"><a href="https://github.com/nxp-imx/uboot-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga" target="_blank">nxp-imx/uboot-imx/releases/tag/rel_imx_4.1.15_2.1.0_ga</a></td>        <td align="left">NXP u-boot仓库tags中的rel_imx_4.1.15_2.1.0_ga</td>    </tr>    <tr>        <td align="center" rowspan="2">I.MX6ULL</td>        <td align="left"><a href="https://www.nxp.com.cn/docs/en/data-sheet/IMX6ULLIEC.pdf" target="_blank">i.MX 6ULL Applications Processors for Industrial Products</a></td>        <td align="left">I.MX6ULL 芯片手册（datasheet，可以在线查看）</td>    </tr>    <tr>        <td align="left"><a href="https://www.nxp.com.cn/webapp/Download?colCode=IMX6ULLRM&lang_cd=zh" target="_blank">i.MX 6ULL Applications ProcessorReference Manual</a></td>        <td align="left">I.MX6ULL 参考手册（下载后才能查看，需要登录NXP官网）</td>    </tr></table>
              </div>
            </details>

<p>我们先来分析一下顶层的Makefile文件。</p>
<h1 id="一、版本号与MAKEFLAGS-变量"><a href="#一、版本号与MAKEFLAGS-变量" class="headerlink" title="一、版本号与MAKEFLAGS 变量"></a><font size=3>一、版本号与MAKEFLAGS 变量</font></h1><h2 id="1-版本号"><a href="#1-版本号" class="headerlink" title="1. 版本号"></a><font size=3>1. 版本号</font></h2><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730101206553.png" alt="image-20230730101206553" style="zoom:50%;" />

<p>VERSION 是主版本号， PATCHLEVEL 是补丁版本号， SUBLEVEL 是次版本号，这三个一起构成了 uboot 的版本号，比如当前的 uboot 版本号是“2016.03”。EXTRAVERSION 是附加版本信息， NAME 是和名字有关的，一般不使用这两个。  </p>
<h2 id="2-MAKEFLAGS-变量"><a href="#2-MAKEFLAGS-变量" class="headerlink" title="2. MAKEFLAGS 变量"></a><font size=3>2. MAKEFLAGS 变量</font></h2><p>make 是支持递归调用的，也就是在 Makefile 中使用“make”命令来执行其他的 Makefile文件，一般都是子目录中的 Makefile 文件。假如在当前目录下存在一个“subdir”子目录，这个子目录中又有其对应的 Makefile 文件，那么这个工程在编译的时候其主目录中的 Makefile 就可以调用子目录中的 Makefile，以此来完成所有子目录的编译。主目录的 Makefile 可以使用如下代码来编译这个子目录：  </p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">$(MAKE)</span> -C subdir</span><br></pre></td></tr></table></figure>

<p>$(MAKE)就是调用“make”命令， -C 指定子目录。有时候我们需要向子 make 传递变量，这个时候使用“export”来导出要传递给子 make 的变量即可，如果不希望哪个变量传递给子make 的话就使用“unexport”来声明不导出:  </p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">export</span> VARIABLE    <span class="comment"># 导出变量给子 make 。</span></span><br><span class="line"><span class="keyword">unexport</span> VARIABLE  <span class="comment"># 不导出变量给子 make。</span></span><br></pre></td></tr></table></figure>

<p>有两个特殊的变量：“SHELL”和“MAKEFLAGS”，这两个变量除非使用“unexport”声明，否则的话在整个make的执行过程中，它们的值始终自动的传递给子make。在uboot的主Makefile中有如下代码：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730101506292.png" alt="image-20230730101506292" style="zoom:50%;" />

<p>上述代码使用“+&#x3D;”来给变量 MAKEFLAGS 追加了一些值，“-rR”表示禁止使用内置的隐含规则和变量定义，“--include-dir”指明搜索路径， ”$(CURDIR)”表示当前目录。  </p>
<h1 id="二、输出？"><a href="#二、输出？" class="headerlink" title="二、输出？"></a><font size=3>二、输出？</font></h1><h2 id="1-命令输出"><a href="#1-命令输出" class="headerlink" title="1. 命令输出"></a><font size=3>1. 命令输出</font></h2><p>uboot 默认编译是不会在终端中显示完整的命令，都是短命令  ：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730101655745.png" alt="image-20230730101655745" style="zoom:50%;" />

<p>在终端中输出短命令虽然看起来很清爽，但是不利于分析 uboot 的编译过程。可以通过设置变量“V&#x3D;1“来实现完整的命令输出，这个在调试 uboot 的时候很有用：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730101821718.png" alt="image-20230730101821718" style="zoom:50%;" />

<p>顶层 Makefile 中控制命令输出的代码如下  ：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730101935202.png" alt="image-20230730101935202" style="zoom: 50%;" />

<p>上述代码中先使用 ifeq 来判断”$(origin V)”和”command line”是否相等。这里用到了 Makefile中的函数 origin， origin 和其他的函数不一样，它不操作变量的值， origin 用于告诉你变量是哪来的，语法为：  </p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">$(<span class="built_in">origin</span> &lt;variable&gt;)</span></span><br></pre></td></tr></table></figure>

<p>variable 是变量名， origin 函数的返回值就是变量来源，因此$(origin V)就是变量 V 的来源。如果变量 V 是在命令行定义的那么它的来源就是”command line”，这样”$(origin V)”和”commandline”就相等了。当这两个相等的时候变量 KBUILD_VERBOSE 就等于 V 的值，比如在命令行中输 入 “ V&#x3D;1 “ 的话那么KBUILD_VERBOSE&#x3D;1 。 如果没有在命令行输入 V 的 话KBUILD_VERBOSE&#x3D;0。</p>
<p>第 80 行判断 KBUILD_VERBOSE 是否为 1，如果 KBUILD_VERBOSE 为 1 的话变量 quiet 和 Q 都为空，如果 KBUILD_VERBOSE&#x3D;0 的话变量 quiet为 “quiet、_“，变量 Q 为“@” ,综上所述：   </p>
<ul>
<li>V&#x3D;1时</li>
</ul>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">KBUILD_VERBOSE=1</span><br><span class="line">quiet=空</span><br><span class="line">Q=空</span><br></pre></td></tr></table></figure>

<ul>
<li>V&#x3D;0 或者命令行不定义 V 的话：</li>
</ul>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">KBUILD_VERBOSE=0</span><br><span class="line">quiet=quiet_</span><br><span class="line">Q=@</span><br></pre></td></tr></table></figure>

<p>Makefile 中会用到变量 quiet 和 Q 来控制编译的时候是否在终端输出完整的命令，在顶层Makefile 中有很多如下所示的命令：  </p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">$(Q)</span><span class="variable">$(MAKE)</span> <span class="variable">$(build)</span>=tools</span><br></pre></td></tr></table></figure>

<p>如果 V&#x3D;0 的话上述命令展开就是“@ make $(build)&#x3D;tools”， make 在执行的时候默认会在终端输出命令，但是在命令前面加上“@”就不会在终端输出命令了。当 V&#x3D;1 的时候 Q 就为空，上述命令就是“make $(build)&#x3D;tools”，因此在 make 执行的过程，命令会被完整的输出在终端上。有些命令会有两个版本，比如</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730102338747.png" alt="image-20230730102338747" style="zoom:50%;" />

<p>sym 命令分为“quiet_cmd_sym”和“cmd_sym”两个版本，这两个命令的功能都是一样的，区别在于 make 执行的时候输出的命令不同。 quiet_cmd_xxx 命令输出信息少，也就是短命令，而 cmd_xxx 命令输出信息多，也就是完整的命令。</p>
<ul>
<li><p>如果变量 quiet 为空的话，整个命令都会输出。</p>
</li>
<li><p>如果变量 quiet 为“quiet_”的话，仅输出短版本。</p>
</li>
<li><p>如果变量 quiet 为“silent_”的话，整个命令都不会输出。</p>
</li>
</ul>
<h2 id="2-静默输出"><a href="#2-静默输出" class="headerlink" title="2. 静默输出  "></a><font size=3>2. 静默输出  </font></h2><p>设置 V&#x3D;0 或者在命令行中不定义 V 的话，编译 uboot 的时候终端中显示的短命令，但是还是会有命令输出，有时候我们在编译 uboot 的时候不需要输出命令，这个时候就可以使用 uboot 的静默输出功能。编译的时候使用“make -s”即可实现静默输出，顶层 Makefile中相应的代码如下：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730102605146.png" alt="image-20230730102605146" style="zoom:50%;" />

<p>第 91 行判断当前正在使用的编译器版本号是否为 4.x，判断$(filter 4.%,$(MAKE_VERSION))和“ ” (空)是否相等，如果不相等的话就成立，执行里面的语句。也就是说 $(filter4.%,$(MAKE_VERSION))不为空的话条件就成立，这里用到了 Makefile 中的 filter 函数，这是个过滤函数，函数格式如下： </p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">$(<span class="built_in">filter</span> &lt;pattern...&gt;,&lt;text&gt;)</span></span><br></pre></td></tr></table></figure>

<p>filter 函数表示以 pattern 模式过滤 text 字符串中的单词，仅保留符合模式 pattern 的单词，可以有多个模式。函数返回值就是符合 pattern 的字符串。因此$(filter 4.%,$(MAKE_VERSION))的含义就是在字符串“ MAKE_VERSION”中找出符合“ 4.%”的字符(%为通配符)，MAKE_VERSION 是make工具的版本号，ubuntu22.04里面默认自带的make工具版本号为GNU Make 4.3，我们可以输入“make -v”查看。因此$(filter 4.%,$(MAKE_VERSION))不为空，条件成立，执行92~94 行的语句。  </p>
<p>第 92 行也是一个判断语句，如果$(filter %s ,$(firstword x$(MAKEFLAGS)))不为空的话条件成立，变量 quiet 等于“silent_”。这里也用到了函数 filter，在$(firstword x$(MAKEFLAGS)))中过滤出符合“%s”的单词。到了函数 firstword，函数 firstword 是获取首单词，函数格式如下：  </p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">$(<span class="built_in">firstword</span> &lt;text&gt;)</span></span><br></pre></td></tr></table></figure>

<p>firstword 函数用于取出 text 字符串中的第一个单词，函数的返回值就是获取到的单词。当使用“make -s”编译的时候，“-s”会作为 MAKEFLAGS 变量的一部分传递给 Makefile。</p>
<h2 id="3-设置编译结果输出目录"><a href="#3-设置编译结果输出目录" class="headerlink" title="3. 设置编译结果输出目录  "></a><font size=3>3. 设置编译结果输出目录  </font></h2><p>uboot 可以将编译出来的目标文件输出到单独的目录中，在 make 的时候使用“O”来指定输出目录，比如“make O&#x3D;out”就是设置目标文件输出到 out 目录中。这么做是为了将源文件和编译产生的文件分开，当然也可以不指定 O 参数，不指定的话源文件和编译产生的文件都在同一个目录内，一般我们不指定 O 参数。顶层 Makefile 中相关的代码如下：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730103740213.png" alt="image-20230730103740213" style="zoom:50%;" />

<p>第 124 行判断“O”是否来自于命令行，如果来自命令行的话条件成立， KBUILD_OUTPUT就为$(O)，因此变量 KBUILD_OUTPUT 就是输出目录。</p>
<p>第 135 行判断 KBUILD_OUTPUT 是否为空。</p>
<p>第 139 行调用 mkdir 命令，创建 KBUILD_OUTPUT 目录，并且将创建成功以后的绝对路径赋值给 KBUILD_OUTPUT。至此，通过 O 指定的输出目录就存在了。  </p>
<h1 id="三、代码检查和模块编译"><a href="#三、代码检查和模块编译" class="headerlink" title="三、代码检查和模块编译  "></a><font size=3>三、代码检查和模块编译  </font></h1><h2 id="1-代码检查"><a href="#1-代码检查" class="headerlink" title="1. 代码检查"></a><font size=3>1. 代码检查</font></h2><p>uboot 支持代码检查，使用命令“make C&#x3D;1”使能代码检查，检查那些需要重新编译的文件。“make C&#x3D;2”用于检查所有的源码文件，顶层 Makefile 中的代码如下：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730103928244.png" alt="image-20230730103928244" style="zoom:50%;" />

<p>第 176 行判断 C 是否来源于命令行，如果 C 来源于命令行，那就将 C 赋值给变量KBUILD_CHECKSRC，如果命令行没有 C 的话 KBUILD_CHECKSRC 就为 0。</p>
<h2 id="2-模块编译"><a href="#2-模块编译" class="headerlink" title="2. 模块编译"></a><font size=3>2. 模块编译</font></h2><p>在 uboot 中允许单独编译某个模块，使用命令 “ make M&#x3D;dir ” 即可，旧语法“ make SUBDIRS&#x3D;dir ”也是支持的。顶层 Makefile 中的代码如下：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730110043912.png" alt="image-20230730110043912" style="zoom:50%;" />

<p>第 186 行判断是否定义了 SUBDIRS ，如果定义了 SUBDIRS ，变量 KBUILD_EXTMOD&#x3D;SUBDIRS，这里是为了支持老语法“make SUBIDRS&#x3D;dir”</p>
<p>第 190 行判断是否在命令行定义了 M，如果定义了的话 KBUILD_EXTMOD&#x3D;$(M)。</p>
<p>第 197 行判断 KBUILD_EXTMOD 时为空，如果为空的话目标_all 依赖 all，因此要先编译出 all。否则的话默认目标_all 依赖 modules，要先编译出modules，也就是编译模块。一般情况下我们不会在 uboot 中编译模块，所以此处会编译 all 这个目标。</p>
<p>第 203 行判断 KBUILD_SRC 是否为空，如果为空的话就设置变量 srctree 为当前目录，即srctree 为“.”，一般不设置 KBUILD_SRC。</p>
<p>第 214 行设置变量 objtree 为当前目录。</p>
<p>第 215 和 216 行分别设置变量 src 和 obj，都为当前目录。</p>
<p>第 218 行设置 VPATH。</p>
<p>第 220 行导出变量 scrtree、 objtree 和 VPATH。  </p>
<h1 id="四、架构相关"><a href="#四、架构相关" class="headerlink" title="四、架构相关"></a><font size=3>四、架构相关</font></h1><h2 id="1-获取主机架构和系统"><a href="#1-获取主机架构和系统" class="headerlink" title="1. 获取主机架构和系统  "></a><font size=3>1. 获取主机架构和系统  </font></h2><p>接下来顶层 Makefile 会获取主机架构和系统，也就是我们电脑的架构和系统：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730110807180.png" alt="image-20230730110807180" style="zoom:50%;" />

<p>第 227 行定义了一个变量 HOSTARCH，用于保存主机架构，这里调用 shell 命令“uname -m”获取架构名称。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730111047127.png" alt="image-20230730111047127" style="zoom: 50%;" />

<p>从图中可以看出当前电脑主机架构为“x86_64”， shell 中的“|”表示管道，意思是将左边的输出作为右边的输入， sed -e 是替换命令，“sed -e s&#x2F;i.86&#x2F;x86&#x2F;”表示将管道输入的字符串中的“i.86”替换为“x86”，其他的“sed -e s”命令同理。对于我的电脑而言， HOSTARCH&#x3D;x86_64。</p>
<p>第 237 行定义了变量 HOSTOS，此变量用于保存主机 OS 的值，先使用 shell 命令“uname -s”来获取主机 OS，结果如图所示：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730111512235.png" alt="image-20230730111512235" style="zoom:50%;" />

<p>可以看出此时的主机 OS 为“Linux”，使用管道将“Linux”作为后面“ tr ‘[:upper:]’ ‘[:lower:]’ ”的输入，“ tr ‘[:upper:]’ ‘[:lower:]’ ”表示将所有的大写字母替换为小写字母，因此得到“linux”。最后同样使用管道，将“ linux ”作为“ sed -e ‘s&#x2F;\(cygwin).*&#x2F;cygwin&#x2F;‘ ”的输入，用于将 cygwin.* 替换为 cygwin 。因此HOSTOS &#x3D; linux。</p>
<p>第 240 行导出 HOSTARCH &#x3D; x86_64， HOSTOS &#x3D; linux。</p>
<h2 id="2-设置目标架构、交叉编译器和配置文件"><a href="#2-设置目标架构、交叉编译器和配置文件" class="headerlink" title="2. 设置目标架构、交叉编译器和配置文件  "></a><font size=3>2. 设置目标架构、交叉编译器和配置文件  </font></h2><p>编 译 uboot 的 时 候 需 要 设 置 目 标 板 架 构 和 交 叉 编 译 器 ，“ make ARCH&#x3D;arm CROSS_COMPILE&#x3D;arm-linux-gnueabihf-”就是用于设置 ARCH 和CROSS_COMPILE，在顶层 Makefile 中代码如下：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730113258820.png" alt="image-20230730113258820" style="zoom:50%;" />

<p>第 245 行判断 HOSTARCH 和 ARCH 这两个变量是否相等，主机架构(变量 HOSTARCH)是x86_64，而我们编译的是 ARM 版本 uboot，肯定不相等，所以CROSS_COMPILE&#x3D; arm-linuxgnueabihf-。从示例代码可以看出，每次编译 uboot 的时候都要在 make 命令后面设置ARCH 和 CROSS_COMPILE，使用起来很麻烦，可以直接修改顶层 Makefile，在里面加入 ARCH和 CROSS_COMPILE 的定义：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730113557320.png" alt="image-20230730113557320" style="zoom:50%;" />

<p>直接在顶层 Makefile 里面定义 ARCH 和 CROSS_COMPILE，这样就不用每次编译的时候都要在 make 命令后面定义 ARCH 和 CROSS_COMPILE。</p>
<p>第 249 行定义变量 KCONFIG_CONFIG， uboot 是可以配置的，这里设置配置文件为.config，.config 默认是没有的，需要使用命令“make xxx_defconfig”对 uboot 进行配置，配置完成以后就会在 uboot 根目录下生成.config。默认情况下.config 和xxx_defconfig 内容是一样的，因为.config 就是从 xxx_defconfig 复制过来的。如果后续自行调整了 uboot 的一些配置参数，那么这些新的配置参数就添加到了.config 中，而不是 xxx_defconfig。<strong>相当于 xxx_defconfig 只是一些初始配置，而.config 里面的才是实时有效的配置</strong>。  </p>
<h1 id="五、scripts-Kbuild-include"><a href="#五、scripts-Kbuild-include" class="headerlink" title="五、scripts&#x2F;Kbuild.include  "></a><font size=3>五、scripts&#x2F;Kbuild.include  </font></h1><p>主 Makefile 会调用文件 scripts&#x2F;Kbuild.include 这个文件，顶层 Makefile 中代码如下：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730114148025.png" alt="image-20230730114148025" style="zoom:50%;" />

<p>make 使用“include”包含了文件 scripts&#x2F;Kbuild.include，此文件里面定义了很多变量：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730115029116.png" alt="image-20230730115029116" style="zoom:50%;" />

<p>在 uboot 的编译过程中会用到 scripts&#x2F;Kbuild.include 中的这些变量。</p>
<h1 id="六、变量相关"><a href="#六、变量相关" class="headerlink" title="六、变量相关"></a><font size=3>六、变量相关</font></h1><h2 id="1-交叉编译工具变量设置"><a href="#1-交叉编译工具变量设置" class="headerlink" title="1. 交叉编译工具变量设置  "></a><font size=3>1. 交叉编译工具变量设置  </font></h2><p>上面我们只是设置了 CROSS_COMPILE 的名字，但是交叉编译器其他的工具还没有设置，顶层 Makefile 中相关代码如下：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730120749352.png" alt="image-20230730120749352" style="zoom:50%;" />

<h2 id="2-导出其他变量"><a href="#2-导出其他变量" class="headerlink" title="2. 导出其他变量  "></a><font size=3>2. 导出其他变量  </font></h2><p>接下来在顶层 Makefile 会导出很多变量：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730120828665.png" alt="image-20230730120828665" style="zoom:50%;" />

<p>后边还有很多，这里只是截取了一部分。这些变量中大部分都已经在前面定义了，我们重点来看一下下面这几个变量：  </p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR</span><br></pre></td></tr></table></figure>

<p>这 7 个变量在顶层 Makefile 是找不到的，说明这 7 个变量是在其他文件里面定义的。先来看一下这 7 个变量都是什么内容，在顶层 Makefile 中输入如图所示的内容：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730121214740.png" alt="image-20230730121214740" style="zoom:50%;" />

<p>然后执行以下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- my_test </span><br></pre></td></tr></table></figure>

<p>然后便会看到如下打印：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730121307139.png" alt="image-20230730121307139" style="zoom:50%;" />

<p>可以看到这 7 个变量的值，这 7 个变量是从哪里来的呢？在 uboot 根目录下有个文件叫做 config.mk，这 7 个变量就是在 config.mk 里面定义的，打开 config.mk 内容如下（只截取了一小部分）：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730121415328.png" alt="image-20230730121415328" style="zoom:50%;" />

<p>接下来需要找到 CONFIG_SYS_ARCH、 CONFIG_SYS_CPU、 CONFIG_SYS_BOARD、CONFIG_SYS_VENDOR 和 CONFIG_SYS_SOC 这 5 个变量的值。这 5 个变量在 uboot 根目录下的.config 文件中有定义，定义如下：  </p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/02IMX6ULL%E5%B9%B3%E5%8F%B0/LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/LV05-01-uboot-06-%E9%A1%B6%E5%B1%82Makefile-01-%E5%9F%BA%E7%A1%80%E5%88%86%E6%9E%90/img/image-20230730121536471.png" alt="image-20230730121536471" style="zoom:50%;" />

<p>所以就有：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">ARCH = arm</span><br><span class="line">CPU = armv7</span><br><span class="line">BOARD = mx6ullevk</span><br><span class="line">VENDOR = freescale</span><br><span class="line">SOC = mx6</span><br><span class="line">CPUDIR = arch/arm/cpu/armv7</span><br><span class="line">BOARDDIR = freescale/mx6ullevk</span><br></pre></td></tr></table></figure>

<p>再来分析config.mk，就会发现在 config.mk 中读取的文件有 :</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">arch/arm/config.mk</span><br><span class="line">arch/arm/cpu/armv7/config.mk</span><br><span class="line">arch/arm/cpu/armv7/mx6/config.mk (此文件不存在)</span><br><span class="line">board/ freescale/mx6ullevk/config.mk (此文件不存在)</span><br></pre></td></tr></table></figure>


    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/aadd7195.html">LV05-01-uboot-06-顶层Makefile-01-基础分析</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2023年09月08日 - 19:22</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/aadd7195.html" title="LV05-01-uboot-06-顶层Makefile-01-基础分析">https://sumumm.github.io/post/aadd7195.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/ALPHA-LV05-uboot%E4%B8%8E%E5%86%85%E6%A0%B8/" rel="tag"><i class="fa fa-tag"></i> (ALPHA)LV05-uboot与内核</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/5c91070d.html" rel="prev" title="LV05-01-uboot-06-顶层Makefile-02-相关过程分析">
                  <i class="fa fa-angle-left"></i> LV05-01-uboot-06-顶层Makefile-02-相关过程分析
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/a7c5ba62.html" rel="next" title="LV05-01-uboot-05-uboot启动内核">
                  LV05-01-uboot-05-uboot启动内核 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
